package java44th.group.service.wx.home;

import java44th.group.bean.admin.vo.BaseRespVo;
import java44th.group.bean.po.MarketAd;
import java44th.group.bean.po.MarketAdExample;
import java44th.group.bean.po.MarketBrand;
import java44th.group.bean.po.MarketCoupon;
import java44th.group.bean.wx.vo.home.*;
import java44th.group.mapper.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @projectName: project-second
 * @package: java44th.group.service.wx.home
 * @className: WxHomeServiceImpl
 * @author: 杨浩祥
 * @description: TODO
 * @date: 2022/10/14 20:14
 * @version: 1.0
 */
@Service
public class WxHomeServiceImpl implements WxHomeService{

    @Autowired
    MarketGoodsMapper goodsMapper;

    @Autowired
    MarketAdMapper adMapper;

    @Autowired
    MarketBrandMapper brandMapper;

    @Autowired
    MarketCategoryMapper categoryMapper;

    @Autowired
    MarketCouponMapper couponMapper;

    @Autowired
    MarketTopicMapper topicMapper;


    @Override
    public BaseRespVo index() {
        // {"errno":0,"data":{"newGoodsList":[{"id":1181136,"name":"发电机房","brief":"","picUrl":"","isNew":true,"isHot":false,"counterPrice":123.00,"retailPrice":0.00},{"id":1181132,"name":"而且十分","brief":"","picUrl":"","isNew":true,"isHot":false,"counterPrice":332.00,"retailPrice":0.00},{"id":1181131,"name":"埃尔奇为","brief":"","picUrl":"","isNew":true,"isHot":false,"counterPrice":1231.00,"retailPrice":0.00},{"id":1181129,"name":"o(=•ェ•=)m猫","brief":"","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/n8z9y2w09208680gzvx2.jpg","isNew":true,"isHot":true,"counterPrice":555.00,"retailPrice":0.00},{"id":1181128,"name":"西红柿","brief":"这是西红柿商品简介","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/i2dqnvkkx0jkxf8puwfy.jpg","isNew":true,"isHot":false,"counterPrice":10.00,"retailPrice":10.00}],"couponList":[{"id":127,"name":"测试券绝对时间每人限领10张版","desc":"","tag":"","discount":0.00,"min":0.00,"days":0,"startTime":"2022-10-13 00:00:00","endTime":"2022-10-20 00:00:00"},{"id":126,"name":"测试券指定时间；发布就过期版","desc":"","tag":"","discount":0.00,"min":0.00,"days":0,"startTime":"2022-10-11 00:00:00","endTime":"2022-10-13 00:00:00"},{"id":125,"name":"测试券相对时间","desc":"","tag":"","discount":0.00,"min":0.00,"days":0}],"channel":[{"id":1005000,"name":"生活","iconUrl":"http://yanxuan.nosdn.127.net/a45c2c262a476fea0b9fc684fed91ef5.png"},{"id":1005001,"name":"餐厨","iconUrl":"http://yanxuan.nosdn.127.net/ad8b00d084cb7d0958998edb5fee9c0a.png"},{"id":1008000,"name":"配件","iconUrl":"http://yanxuan.nosdn.127.net/11abb11c4cfdee59abfb6d16caca4c6a.png"},{"id":1008017,"name":"收纳","iconUrl":"http://yanxuan.nosdn.127.net/fdc048e1bf4f04d1c20b32eda5d1dc6e.png"},{"id":1010000,"name":"服装","iconUrl":"http://yanxuan.nosdn.127.net/28a685c96f91584e7e4876f1397767db.png"},{"id":1011000,"name":"婴童","iconUrl":"http://yanxuan.nosdn.127.net/1ba9967b8de1ac50fad21774a4494f5d.png"},{"id":1013001,"name":"洗护","iconUrl":"http://yanxuan.nosdn.127.net/9fe068776b6b1fca13053d68e9c0a83f.png"},{"id":1019000,"name":"志趣","iconUrl":"http://yanxuan.nosdn.127.net/7093cfecb9dde1dd3eaf459623df4071.png"},{"id":1036023,"name":"坦克","iconUrl":"http://182.92.235.201:8083/wx/storage/fetch/2cx6fga0jb1tjhg4vr0o.jpg"},{"id":1036038,"name":"能源","iconUrl":"http://182.92.235.201:8083/wx/storage/fetch/3ekc77klydqcipn1qahj.jpg"},{"id":1036057,"name":"健身","iconUrl":"http://182.92.235.201:8083/wx/storage/fetch/9d5h9qukru434khpw8ln.jpg"},{"id":1036101,"name":"华为手机","iconUrl":"http://182.92.235.201:8083/wx/storage/fetch/q55cskc7tc8n592jlf4e.jpeg"},{"id":1036121,"name":"类目名称","iconUrl":"http://182.92.235.201:8083/wx/storage/fetch/92wbvj7hsgjgmewpu5bu.png"},{"id":1036130,"name":"红豆","iconUrl":""},{"id":1036133,"name":"雨具","iconUrl":""},{"id":1036134,"name":"雨具","iconUrl":"http://182.92.235.201:8083/wx/storage/fetch/jooqw0v1z4yeevvd7v4r.jpg"},{"id":1036141,"name":"哈哈","iconUrl":""},{"id":1036144,"name":"一级类目","iconUrl":""},{"id":1036152,"name":"喜喜","iconUrl":""},{"id":1036171,"name":"777","iconUrl":""},{"id":1036177,"name":"重案六组专用一级类目333","iconUrl":""}],"banner":[{"id":1,"name":"合作 谁是你的菜","link":"","url":"http://yanxuan.nosdn.127.net/65091eebc48899298171c2eb6696fe27.jpg","position":1,"content":"合作 谁是你的菜","enabled":true,"addTime":"2018-02-01 00:00:00","updateTime":"2022-09-09 13:55:29","deleted":false},{"id":7,"name":"阿萨","link":"as","url":"http://182.92.235.201:8083/wx/storage/fetch/8rtskszsj1l5c3mvpdrw.jpg","position":1,"content":"哒","enabled":true,"addTime":"2022-09-06 21:14:31","updateTime":"2022-09-06 23:31:32","deleted":false},{"id":23,"name":"asdsa","link":"123456789","url":"http://182.92.235.201:8083/wx/storage/fetch/zlxq5a70kf0qqdnbbhae.jpg","position":1,"content":"asddsa","enabled":true,"addTime":"2022-09-07 13:52:05","updateTime":"2022-09-07 14:47:19","deleted":false},{"id":24,"name":"？？","link":"http://cskaoyan.com","url":"http://182.92.235.201:8083/wx/storage/fetch/wthnsvatc9wmx5vvyw9j.jpg","position":1,"content":"123","enabled":true,"addTime":"2022-09-07 13:54:10","updateTime":"2022-09-07 16:51:13","deleted":false},{"id":37,"name":"哦哦哦","link":"开启","url":"http://182.92.235.201:8083/wx/storage/fetch/jynobgl1y378sjam5dmj.png","position":1,"content":"123","enabled":true,"addTime":"2022-09-08 14:26:49","updateTime":"2022-09-08 14:26:49","deleted":false},{"id":41,"name":"test19:07","link":"http://182.92.235.201/#/promotion/ad","url":"http://182.92.235.201:8083/wx/storage/fetch/g2kjip8vk1pecu7hve3e.jpg","position":1,"content":"test","enabled":true,"addTime":"2022-09-08 19:08:10","updateTime":"2022-09-08 19:08:10","deleted":false},{"id":47,"name":"帅的测试劵","link":"https://www.4399.com","url":"http://182.92.235.201:8083/wx/storage/fetch/equg7o6bj5wvmq2ll3yb.jpg","position":1,"content":"卧槽好帅1","enabled":true,"addTime":"2022-10-11 17:28:32","updateTime":"2022-10-12 14:35:32","deleted":false},{"id":50,"name":"测试","link":"5555","url":"http://182.92.235.201:8083/wx/storage/fetch/3kwxrtq424dzcpuqf76o.png","position":1,"content":"测试3","enabled":true,"addTime":"2022-10-11 21:12:38","updateTime":"2022-10-13 16:33:43","deleted":false},{"id":51,"name":"测试","link":"水电费","url":"http://182.92.235.201:8083/wx/storage/fetch/ftqead1hih1d66rsi2js.png","position":1,"content":"测试4","enabled":true,"addTime":"2022-10-11 21:12:51","updateTime":"2022-10-11 21:12:51","deleted":false},{"id":62,"name":"dwa","link":"","url":"http://182.92.235.201:8083/wx/storage/fetch/wsf1y0cbcw479353cq3l.jpg","position":1,"content":"fa","enabled":true,"addTime":"2022-10-12 11:00:21","updateTime":"2022-10-12 11:00:21","deleted":false},{"id":68,"name":"我再添加","link":"广告位置是只有首页？？","url":"http://182.92.235.201:8083/wx/storage/fetch/mj3b1vgnoxvidwgorxpb.jpg","position":1,"content":"这是内容","enabled":true,"addTime":"2022-10-12 14:25:05","updateTime":"2022-10-12 14:25:05","deleted":false},{"id":69,"name":"这是一条长长长长长长长长的标题","link":"这是一条链接；让我康康时间","url":"http://182.92.235.201:8083/wx/storage/fetch/3m0h15shicldx4zvx9w1.jpg","position":1,"content":"标题很长，测试一下，182使用了异常处理哦","enabled":true,"addTime":"2022-10-12 15:26:49","updateTime":"2022-10-12 15:42:34","deleted":false},{"id":77,"name":"长度测试长度测试长度测试长度测试长度测试长度测试长度测试长度测试长度测试长度测试长度测试长度测试长度测试长度测试","link":"长度测试长度测试长度测试长度测试长度测试长度测试","url":"http://182.92.235.201:8083/wx/storage/fetch/qfg7murz75fqhxmaud7u.jpg","position":1,"content":"长度测试长度测试长度测试长度测试长度测试","enabled":true,"addTime":"2022-10-12 21:25:39","updateTime":"2022-10-12 21:25:39","deleted":false},{"id":87,"name":"121","link":"222","url":"http://182.92.235.201:8083/wx/storage/fetch/tz0fgsey8eml6n4oyzc8.jpg","position":1,"content":"152","enabled":true,"addTime":"2022-10-13 11:53:13","updateTime":"2022-10-13 11:53:13","deleted":false},{"id":88,"name":"23","link":"3244","url":"http://182.92.235.201:8083/wx/storage/fetch/ytilkba8wljpcwr496wr.jpg","position":1,"content":"3232","enabled":true,"addTime":"2022-10-13 11:55:14","updateTime":"2022-10-13 11:55:14","deleted":false},{"id":89,"name":"11","link":"","url":"http://182.92.235.201:8083/wx/storage/fetch/e2rh86h6tv08gtmt0fd6.jpg","position":1,"content":"11","enabled":true,"addTime":"2022-10-13 17:04:31","updateTime":"2022-10-13 17:21:49","deleted":false},{"id":91,"name":"标题","link":"","url":"http://182.92.235.201:8083/wx/storage/fetch/pqacgm02a41d2u930t4o.jpeg","position":1,"content":"广告内容","enabled":true,"addTime":"2022-10-13 20:32:58","updateTime":"2022-10-13 20:32:58","deleted":false}],"brandList":[{"id":1001000,"name":"MUJI制造商","desc":"严选精选了MUJI制造商和生产原料，\n用几乎零利润的价格，剔除品牌溢价，\n让用户享受原品牌的品质生活。","picUrl":"http://yanxuan.nosdn.127.net/1541445967645114dd75f6b0edc4762d.png","floorPrice":12.90},{"id":1001002,"name":"内野制造商","desc":"严选从世界各地挑选毛巾，最终选择了为日本内野代工的工厂，追求毛巾的柔软度与功能性。品质比肩商场几百元的毛巾。","picUrl":"http://yanxuan.nosdn.127.net/8ca3ce091504f8aa1fba3fdbb7a6e351.png","floorPrice":29.00},{"id":1001003,"name":"Adidas制造商","desc":"严选找到为Adidas等品牌制造商，\n选取优质原材料，与厂方一起设计，\n为你提供好的理想的运动装备。","picUrl":"http://yanxuan.nosdn.127.net/335334d0deaff6dc3376334822ab3a2f.png","floorPrice":49.00},{"id":1001007,"name":"优衣库制造商","desc":"严选找到日本知名服装UNIQLO的制造商，\n选取优质长绒棉和精梳工艺，\n与厂方一起设计，为你提供理想的棉袜。","picUrl":"http://yanxuan.nosdn.127.net/0d72832e37e7e3ea391b519abbbc95a3.png","floorPrice":29.00},{"id":1001008,"name":"膳魔师制造商","desc":"严选深入保温行业内部，\n找到德国膳魔师制造商的代工厂。\n同样的品质，却有更优的价格。","picUrl":"http://yanxuan.nosdn.127.net/5fd51e29b9459dae7df8040c8219f241.png","floorPrice":45.00}],"hotGoodsList":[{"id":1181129,"name":"o(=•ェ•=)m猫","brief":"","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/n8z9y2w09208680gzvx2.jpg","isNew":true,"isHot":true,"counterPrice":555.00,"retailPrice":0.00},{"id":1181090,"name":"海尔电视","brief":"实在是好","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/a7xii1nxgmhodsswbqi7.jpg","isNew":true,"isHot":true,"counterPrice":5000.00,"retailPrice":0.00},{"id":1181086,"name":"手机","brief":"华为牛逼","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/f0uzzuz0rw02ris2mw5a.jpeg","isNew":true,"isHot":true,"counterPrice":8888.00,"retailPrice":0.00},{"id":1181073,"name":"保时捷","brief":"保时捷，loser身份的象征","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/te1gz2kztteau8uf627g.jpg","isNew":false,"isHot":true,"counterPrice":2.89,"retailPrice":1.99},{"id":1181067,"name":"zxcvbnm","brief":"简介","picUrl":"","isNew":true,"isHot":true,"counterPrice":1024.00,"retailPrice":2048.00}],"topicList":[{"id":406,"title":"相关专题是干嘛的？","subtitle":"老师叫我们自己写，比如可以推荐有相同商品的专题","price":44444.00,"readCount":"1k","picUrl":""},{"id":405,"title":"好消息不断","subtitle":"2022","price":2300.00,"readCount":"1k","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/uua0v8f4bez114g0b4g4.jpg"},{"id":369,"title":"无职转生","subtitle":"洛琪希","price":888888.00,"readCount":"5M","picUrl":""},{"id":368,"title":"刀剑神域","subtitle":"优纪","price":10000.00,"readCount":"100000000","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/yic99hqnaprpyt13ktkt.jpg"},{"id":366,"title":"固态硬盘","subtitle":"致钛5000Tiplus","price":1269.00,"readCount":"1234778","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/rhw3rxyhffriyxqubetw.jpg"}],"floorGoodsList":[{"name":"生活","goodsList":[{"id":1181090,"name":"海尔电视","brief":"实在是好","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/a7xii1nxgmhodsswbqi7.jpg","isNew":true,"isHot":true,"counterPrice":5000.00,"retailPrice":0.00},{"id":1181085,"name":"111","brief":"1哈哈哈哈","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/bonazccbl0maembuooml.jpg","isNew":true,"isHot":false,"counterPrice":1111.00,"retailPrice":99.00},{"id":1181051,"name":"2233抱枕","brief":"2233娘抱枕，你值得拥有","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/78fasqprem8v0740nfiy.jpg","isNew":true,"isHot":false,"counterPrice":99.00,"retailPrice":79.00},{"id":1181049,"name":"抱枕","brief":"这是一个商品简介","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/1e1io7gcjc2nuo5a1te0.png","isNew":true,"isHot":false,"counterPrice":99.00,"retailPrice":79.00},{"id":1110016,"name":"天然硅胶宠物除毛按摩刷","brief":"顺滑平面，猫狗通用，去除死毛","picUrl":"http://yanxuan.nosdn.127.net/3bd73b7279a83d1cbb50c0e45778e6d6.png","isNew":true,"isHot":false,"counterPrice":59.00,"retailPrice":39.00}],"id":1005000},{"name":"餐厨","goodsList":[{"id":1181077,"name":"这是商品测试名称","brief":"这是商品简介","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/8718ftzpkmactshaivkg.jpg","isNew":true,"isHot":false,"counterPrice":399.00,"retailPrice":0.00},{"id":1181075,"name":"这是名称（测试）","brief":"这是商品简介","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/34zj1vd7yp3lahzajd8k.jpg","isNew":true,"isHot":false,"counterPrice":599.00,"retailPrice":299.00},{"id":1181047,"name":"撒库拉酱","brief":"四川特产","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/u6gh23ltveqerboblyng.jpg","isNew":false,"isHot":false,"counterPrice":34565.00,"retailPrice":13243.00},{"id":1023003,"name":"100年传世珐琅锅 全家系列","brief":"特质铸铁，大容量全家共享","picUrl":"http://yanxuan.nosdn.127.net/c39d54c06a71b4b61b6092a0d31f2335.png","isNew":false,"isHot":false,"counterPrice":418.00,"retailPrice":398.00},{"id":1073008,"name":"铸铁珐琅牛排煎锅","brief":"沥油隔水，煎出外焦里嫩","picUrl":"http://yanxuan.nosdn.127.net/619e46411ccd62e5c0f16692ee1a85a0.png","isNew":false,"isHot":false,"counterPrice":169.00,"retailPrice":149.00}],"id":1005001},{"name":"配件","goodsList":[{"id":1181117,"name":"XXXXX手机","brief":"简介","picUrl":"","isNew":true,"isHot":false,"counterPrice":299999.00,"retailPrice":1000.00},{"id":1181116,"name":"果果","brief":"测试","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/0jgigvt2vis6laejo4vw.jpg","isNew":true,"isHot":false,"counterPrice":100.00,"retailPrice":100.00},{"id":1181114,"name":"果","brief":"hhhh","picUrl":"","isNew":true,"isHot":false,"counterPrice":100.00,"retailPrice":100.00},{"id":1181088,"name":"asdd","brief":"","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/iczb2q5o95e4l9z799gw.jpeg","isNew":true,"isHot":false,"counterPrice":1231.00,"retailPrice":0.00},{"id":1181038,"name":"213","brief":"wqer","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/uvgvnxpnlbxnazssj0gh.png","isNew":true,"isHot":false,"counterPrice":1234.00,"retailPrice":234.00}],"id":1008000},{"name":"收纳","goodsList":[{"id":1181089,"name":"液晶电视","brief":"实在是好","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/3rmemgju4vd83vayus7o.jpg","isNew":true,"isHot":false,"counterPrice":5000.00,"retailPrice":0.00}],"id":1008017},{"name":"服装","goodsList":[{"id":1181082,"name":"黑丝","brief":"黑丝","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/zikpr1o6cowe09ngzmm0.jpg","isNew":true,"isHot":false,"counterPrice":300.00,"retailPrice":20.00},{"id":1181081,"name":"西装","brief":"很帅","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/7ya8e0nsoce1252rovbl.jpg","isNew":true,"isHot":false,"counterPrice":999.00,"retailPrice":999.00},{"id":1181076,"name":"12414","brief":"去","picUrl":"","isNew":true,"isHot":false,"counterPrice":100.00,"retailPrice":0.00},{"id":1181074,"name":"goodsdetail测试","brief":"测试","picUrl":"http://182.92.235.201:8083/wx/storage/fetch/3i6uwaskd34lr8w3xz7z.png","isNew":true,"isHot":false,"counterPrice":100.00,"retailPrice":50.00},{"id":1181067,"name":"zxcvbnm","brief":"简介","picUrl":"","isNew":true,"isHot":true,"counterPrice":1024.00,"retailPrice":2048.00}],"id":1010000}]},"errmsg":"成功"}
        HomeIndexVO homeIndexVO = new HomeIndexVO();

        // 获取ad数据
        MarketAdExample marketAdExample = new MarketAdExample();
        marketAdExample.createCriteria().andDeletedEqualTo(false);
        List<MarketAd> marketAds = adMapper.selectByExample(marketAdExample);
        homeIndexVO.setBanner(marketAds);

        // 获取brand数据
        List<BrandListVO> brandListVOList = brandMapper.selectPartColoumn();
        homeIndexVO.setBrandList(brandListVOList);

        // 获取category数据
        List<ChannelVO> channelVOList = categoryMapper.selectPartColoumn();
        homeIndexVO.setChannel(channelVOList);

        // 获取coupon数据
        List<CouponListVO> couponList = couponMapper.selectPartColoumn();
        homeIndexVO.setCouponList(couponList);

        // 获取pid=0 category 5条数据
        List<FloorGoodsListVO> floorGoodsList = goodsMapper.selectFloorGoods();
        homeIndexVO.setFloorGoodsList(floorGoodsList);

        // 获取热门goods 5tiao
        List<HotGoodsListVO> hotGoodsList = goodsMapper.selectHotGoods();
        homeIndexVO.setHotGoodsList(hotGoodsList);

        // 获取新的goods
        List<NewGoodsListVO> newGoodsList = goodsMapper.selectNewGoodsList();
        homeIndexVO.setNewGoodsList(newGoodsList);

        // 获取topic
        List<TopicListVO> topicList = topicMapper.selectTopicList();
        homeIndexVO.setTopicList(topicList);

        return BaseRespVo.ok(homeIndexVO);
    }
}
